package com.app.Activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.app.Controller.NetworkController;
import com.app.Controller.ReadWriteFileController;
import com.app.Network.Protocol;
import com.app.outdoor.InvoikeServices.CommonInvoike;

public class od_VaoThaoLuanActivity extends Activity {
	TextView txtMsg;
	Button btnDongY, btnTuChoi;
	int idNguoiGui;
	int idNhom;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.od_activity_vao_thao_luan);
        txtMsg=(TextView)findViewById(R.id.txtMsg);
        btnDongY=(Button)findViewById(R.id.btnDongY);
        btnTuChoi=(Button)findViewById(R.id.btnTuChoi);
        btnTuChoi.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();			
			}
		});
        btnDongY.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				try{
					CommonInvoike.vaoNhomThaoLuan(CommonUtilities.nguoiDung.getId(), idNguoiGui);
					CommonUtilities.idNhomHienTai=idNhom;
					NetworkController._peer.getAccount().isThanhLapNhom=false;
				}catch (Exception e) {
					Log.d(Protocol.TAG,"Không thể vào nhóm"+e.getMessage());
				}
				finish();
			}
		});
        Intent intent=getIntent();
        String msg="tạo 1 thảo luận mới! Bạn có muốn tham gia!";
        if(intent!=null){
        	idNguoiGui=Integer.parseInt(intent.getStringExtra(Protocol.NGUOI_GUI));
        	idNhom=Integer.parseInt(intent.getStringExtra(Protocol.ID_NHOM));
        	msg=idNguoiGui+msg;
        }
        txtMsg.setText(msg);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.od_activity_vao_thao_luan, menu);
        return true;
    }

    
}
